﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FormsAppT8
{
    public partial class MDIParent1 : Form
    {
        //private int childFormNumber = 0;

        public MDIParent1()
        {
            InitializeComponent();
        }
        //修改密码
        private void ShowNewForm(object sender, EventArgs e)
        {
            //string str= loginTxtWR.GetV("//users", "user");
            //FormPassword  fm = new FormPassword(str);
            //fm.ShowDialog();
        }
      
        
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
               

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }
            
        private void MDIParent1_Load(object sender, EventArgs e)
        {
            Login llfm = new Login();
            while (true)
            {
                try
                {
                    if (llfm.ShowDialog() == DialogResult.OK)
                    {
                        this.toolStripStatusLabel1.Text = "操作人：admin";//+ loginTxtWR.GetV("//users", "name");
                        //FormT8XH fm = new FormT8XH();  //仓库箱麦
                        //FormT8Fini fm = new FormT8Fini();  //成品标签
                        //FormT8Semi fm = new FormT8Semi();  //半成品标签
                        BQFROMYL fm = new BQFROMYL();  //掂货装箱
                        fm.MdiParent = this;
                        fm.WindowState = FormWindowState.Maximized;
                        fm.Show();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    break;
                }
            }
        }


        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            //FormT8XM fm = new FormT8XM();
            //bool isOpened = false;
            //foreach (Form fff in this.MdiChildren)
            //{
            //    if (fm.Name == fff.Name)
            //    {
            //        fff.Activate();
            //        isOpened = true;
            //        fm.Dispose();
            //        break;
            //    }
            //}
            //if (!isOpened)
            //{
            //    fm.MdiParent = this;
            //    fm.WindowState = FormWindowState.Maximized;
            //    fm.Show();
            //}

        }


        private void MDIParent1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //loginTxtWR.AppClosing();
           
            
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            BQFROMYL fm = new BQFROMYL();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }

        }

        private void ToolStripMenuItem1A_Click(object sender, EventArgs e)
        {
            BQFROMYL fm = new BQFROMYL();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            BQFROMCK fm = new BQFROMCK();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void 仓库标签ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BQFROMCK fm = new BQFROMCK();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            BQFROMKC fm = new BQFROMKC();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void 物料标签ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BQFROMKC fm = new BQFROMKC();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            BQFROMSC fm = new BQFROMSC();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {

            BQFROMFH fm = new BQFROMFH();
            bool isOpened = false;
            foreach (Form fff in this.MdiChildren)
            {
                if (fm.Name == fff.Name)
                {
                    fff.Activate();
                    isOpened = true;
                    fm.Dispose();
                    break;
                }
            }
            if (!isOpened)
            {
                fm.MdiParent = this;
                fm.WindowState = FormWindowState.Maximized;
                fm.Show();
            }
        }
    }
}
